<%@page import="org.apache.taglibs.standard.tag.common.xml.IfTag"%>
<%@page import="org.apache.jasper.tagplugins.jstl.core.If"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"+"post/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
   <meta charset="utf-8">
<title>问题详情</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="keywords" content="fly,layui,前端社区">
<meta name="description" content="Fly社区是模块化前端UI框架Layui的官网社区，致力于为web开发提供强劲动力">
<link rel="stylesheet" href="../res/layui/css/layui.css">
<link rel="stylesheet" href="../res/css/global.css">
<script src="../res/layui/layui.js"></script>
<script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
<style type="text/css" rel="stylesheet">
form {
	margin: 0;
}

.editor {
	margin-top: 5px;
	margin-bottom: 5px;
}
</style>
</head>
<body>
	<!-- <div class="header">
		<div class="main">
			<a class="logo" href="index.html" title="网博">网博社区</a>
			<div class="nav">
				<a class="nav-this" href="index.html"> <i
					class="iconfont icon-wenda"></i>问答 </a>
			</div>

			<div class="nav-user">
				登入后的状态

				<a class="avatar" href="../user/home.html"> <img
					src="../res/images/avatar/11.jpg"> <cite>贤心</cite>
					<i>VIP</i> </a>
				<div class="nav">
					<a href="../user/set.html"><i class="iconfont icon-shezhi"></i>设置</a>
					<a href="../user/login.html"><i class="iconfont icon-tuichu"
						style="top: 0; font-size: 22px;"></i>退了</a>
				</div>
			</div>
		</div>
	</div> -->

	<div class="main layui-clear">
		<div class="wrap">
			<div class="content detail">
				<div class="fly-panel detail-box">
					<h1>${post.postTitle }</h1>
					<div class="fly-tip fly-detail-hint" data-id="">
						<c:if test="${post.postStatus == '未结贴' }">	<!-- 已结贴的帖子没有置顶帖 -->
							<c:if test="${post.postStick == '已置顶' }"><span class="fly-tip-stick">置顶帖</span></c:if>
							<span>未结贴</span>
						</c:if>
						<c:if test="${post.postStatus == '已结贴' }"><span class="fly-tip-jie">已采纳</span></c:if>
						<c:if test="${userName == User.userName }">	<!-- 进行帖子的置顶（发帖本人且是会员） -->
							<c:if test="${post.postStatus == '未结贴' }">	<!-- 已结贴的帖子无法置顶 -->
								<c:if test="${post.postStick == '未置顶' }"><span class="jie-admin"><a href="toStickOrNot?userId=${User.userId }&postId=${post.postId }&stickOrNot=yes">点击置顶</a></span></c:if>
								<c:if test="${post.postStick == '已置顶' }"><span class="layui-btn layui-btn-mini jie-admin"><a href="toStickOrNot?userId=${User.userId }&postId=${post.postId }&stickOrNot=no">取消置顶</a></span></c:if>
							</c:if>
						</c:if>
						<%-- <c:if test="${rightRoleId == 0 }">	<!-- 删帖，管理员功能 -->
							<span class="jie-admin" type="del" style="margin-left: 20px;"><a>删除该帖</a></span>
						</c:if> --%>
						<!-- 举报 -->
						<c:if test="${User.userName != null }">	<!-- 用户登录后才可操作 -->
							<c:if test="${isReport != null }">
								<span class="fly-tip-jie">已举报</span> 
							</c:if>
							<c:if test="${User.userId != post.postUserId }">	<!-- 自己不能举报自己 -->
								<span class="fly-tip-jie"><a href="toReport?postId=${post.postId }
											&postUserId=${post.postUserId }
											&reportUserId=${User.userId }
											&postTitle=${post.postTitle }">举报</a></span>
							</c:if>
						</c:if>

						<div class="fly-list-hint">
							<i class="iconfont" title="回答">&#xe60c;</i> ${post.postReply } <i class="iconfont"
								title="人气">&#xe60b;</i> ${post.postBrowse }
						</div>
					</div>
					<div class="detail-about">
						<a class="jie-user" href="../user/home.html"> <img
							src="../res/images/avatar/0.jpg" alt="头像"> <cite> ${userName }
								<em><fmt:formatDate value="${post.postCreateTime }" pattern="yyyy-MM-dd HH:mm"/>发布</em> </cite> </a>
						<div class="detail-hits" data-id="{{rows.id}}">
							<span style="color:#FF7200">悬赏：${post.postReward }飞吻</span> 
							<c:if test="${userName == User.userName }">	<!-- 发帖人才可看见师傅编辑帖子 -->
								<c:if test="${post.postStatus == '未结贴' }">
									<span class="layui-btn layui-btn-mini jie-admin"><a href="#">编辑此贴</a></span>
								</c:if>
								<c:if test="${post.postStatus == '已结贴' }">
									<span class="layui-btn layui-btn-mini jie-admin"><a href="#">已完帖，无法编辑</a></span> 
								</c:if>
							</c:if> 
							<%-- <c:if test="${userName != User.userName }"> --%>	<!-- 自己不可以收藏自己的帖子 -->
							<c:if test="${User.userName != null }">	<!-- 用户登录后才可收藏 -->
								<c:if test="${isCollect == '未收藏' }">
									<span class="layui-btn layui-btn-mini jie-admin" type="collect" data-type="add"> 
										<a href="toCollectOrNot?postId=${post.postId }
												&postUserId=${post.postUserId }
												&userId=${User.userId }">收藏</a> 
									</span> 
								</c:if>
							</c:if>
							<c:if test="${isCollect == '已收藏' }">
								<span class="layui-btn layui-btn-mini jie-admin  layui-btn-danger" type="collect" data-type="add"> 
									<a href="toCollectOrNot?postId=${post.postId }
											&postUserId=${post.postUserId }
											&userId=${User.userId }">取消收藏</a> 
								</span>
							</c:if>
							<!-- 回复楼主 -->
							<span class="layui-btn layui-btn-mini jie-admin  layui-btn-normal" data-type="add"> 
								<a href="javascript:void(0)" onclick="document.getElementById('toReply').scrollIntoView();">回复楼主</a>
							</span>
							<%-- </c:if> --%>

						</div>

					</div>

					<div class="detail-body photos" style="margin-bottom: 20px;">
						<p>${post.postContent }</p>
					</div>
				</div>

				
				<div class="fly-panel detail-box" style="padding-top: 0;">
					<a name="comment"></a>
					<ul class="jieda photos" id="jieda">
					
						<!-- 循环打印 -->
						<c:forEach items="${requestScope.replyMsg.lists }" var="reply" varStatus="loop">
						<c:if test="${reply.replyStatus == '最佳答案' }">
						<li data-id="12" class="jieda-daan"><a
							name="item-121212121212"></a>
							<div class="detail-about detail-about-reply">
								<!-- 头像，用户名 -->
								<a class="jie-user" href="../user/home.html"> <img
									src="../res/images/avatar/0.jpg" alt=""> <cite> <i>${userReply[loop.count-1].userName }</i>
										<!-- <em>(楼主)</em>
                  <em style="color:#5FB878">(管理员)</em> --> </cite> </a>
								<!-- 回复时间 -->
								<div class="detail-hits">
									<span><fmt:formatDate value="${reply.replyCreateTime }" pattern="yyyy-MM-dd HH:mm"/></span>
								</div>
								<i class="iconfont icon-caina" title="最佳答案"></i>
							</div>
							<!-- 回复内容 -->
							<div class="detail-body jieda-body">
								<!-- 判断是否回复的是楼主 -->
								<c:if test="${reply.replyByReplyUserId == post.postUserId }">
									<p>${reply.replyContent }</p>
								</c:if>
								<c:if test="${reply.replyByReplyUserId != post.postUserId }">
									<p>@${reply.replyByReplyUserId }: ${reply.replyContent }</p>
								</c:if>
							</div>
							<!-- 点赞，回复按钮 -->
							<div class="jieda-reply">
								<!-- 点赞 class="jieda-zan zanok" -->
								<a href="toLikeReply?replyId=${reply.replyId }
									&likePostId=${post.postId }
									&likePostUserId=${post.postUserId }
									&likeReplyId=${reply.replyId }
									&likeFromUserId=${User.userId }
									&likeByUserId=${reply.replyFromReplyUserId }">
									<!-- 循环判断 -->
									<%-- <c:forEach items="${isLike }" var="like" varStatus="loop2">
										<c:if test="${like.likeReplyId == reply.replyId }">
											<span class="jieda-zan zanok" type="zan"><i class="iconfont icon-zan"></i><em>${reply.replyLike }</em></span>
										</c:if>	<!-- 点亮 -->
									</c:forEach> --%>
									<%-- <c:forEach items="${isLike }" var="like" varStatus="loop3">
										<c:if test="${like.likeReplyId != reply.replyId or isLike == null }"> --%>
											<c:if test="${User.userId != reply.replyFromReplyUserId }">	<!-- 自己的回复无法点赞 -->
												<span class="jieda-zan" type="zan"><i class="iconfont icon-zan"></i><em>${reply.replyLike }</em></span>
											</c:if>
										<%-- </c:if>	<!-- 未点亮 -->
									</c:forEach> --%>
								</a>
								<!-- 回复按钮 -->
								<span type="reply"><i class="iconfont icon-svgmoban53"></i>
									<a href="showPostDetail?postId=${post.postId }&byReplyName=${userReply[loop.count-1].userName }">回复</a>
								</span>
								<!-- <div class="jieda-admin">
                <span type="del">删除</span>
                <span class="jieda-accept" type="accept">采纳</span>
              </div> -->
							</div></li>
						</c:if>
						</c:forEach>

						<c:forEach items="${requestScope.replyMsg.lists }" var="reply" varStatus="loop">
						<c:if test="${reply.replyStatus == '普通回帖' }">
						<li data-id="13"><a name="item-121212121212"></a>
							<div class="detail-about detail-about-reply">
								<!-- 头像，用户名 -->
								<a class="jie-user" href="../user/home.html"> <img
									src="../res/images/avatar/0.jpg" alt=""> <cite> <i>${userReply[loop.count-1].userName }</i>
										<!-- 称号？ -->
										<%-- <em style="color:#FF9E3F">活雷锋</em> </cite>  --%>
								</a>
								<!-- 回复时间 -->
								<div class="detail-hits">
									<span><fmt:formatDate value="${reply.replyCreateTime }" pattern="yyyy-MM-dd HH:mm"/></span>
								</div>
							</div>
							<!-- 回复内容 -->
							<div class="detail-body jieda-body">
								<!-- 判断是否回复的是楼主 -->
								<c:if test="${reply.replyByReplyUserId == post.postUserId }">
									<p>${reply.replyContent }</p>
								</c:if>
								<c:if test="${reply.replyByReplyUserId != post.postUserId }">
									<c:forEach items="${replyUserList }" var="rUserList" varStatus="loop2">
										<c:if test="${reply.replyByReplyUserId == rUserList.userId }">
											<p>@${rUserList.userName }: ${reply.replyContent }</p>
										</c:if>
									</c:forEach>
								</c:if>
							</div>
							<!-- 点赞，回复按钮 -->
							<div class="jieda-reply">
								<!-- 点赞 class="jieda-zan" -->
								<a href="toLikeReply?replyId=${reply.replyId }
									&likePostId=${post.postId }
									&likePostUserId=${post.postUserId }
									&likeReplyId=${reply.replyId }
									&likeFromUserId=${User.userId }
									&likeByUserId=${reply.replyFromReplyUserId }">
									<!-- 循环判断 -->
									<%-- <c:forEach items="${isLike }" var="like" varStatus="loop2">
										<c:if test="${like.likeReplyId == reply.replyId }">
											<span class="jieda-zan zanok" type="zan"><i class="iconfont icon-zan"></i><em>${reply.replyLike }</em></span>
										</c:if>	<!-- 点亮 -->
									</c:forEach> --%>
									<%-- <c:forEach items="${isLike }" var="like" varStatus="loop3">
										<c:if test="${like.likeReplyId == isNotLike[loop3.count-1] or isLike == null }"> --%>	<!-- 点赞了该贴中的其中一个回复或谁都没点赞的情况 -->
											<c:if test="${User.userId != reply.replyFromReplyUserId }">	<!-- 自己的回复无法点赞 -->
												<span class="jieda-zan" type="zan"><i class="iconfont icon-zan"></i><em>${reply.replyLike }</em></span>
											</c:if>
										<%-- </c:if>	<!-- 未点亮 -->
									</c:forEach> --%>
								</a>
								<!-- 回复按钮 -->
								<span type="reply"><i class="iconfont icon-svgmoban53"></i>
									<a href="showPostDetail?postId=${post.postId }&byReplyName=${userReply[loop.count-1].userName }">回复</a>
								</span>
								<div class="jieda-admin">
									<!-- 删除帖子，管理员功能 -->
									<span type="del"><a href="#" class="layui-btn layui-btn-danger layui-btn-small">删除</a></span>
									<!-- 采纳回复 -->
									<!-- 采纳人是楼主本人 -->	<!-- 回帖人不是发帖人时才可采纳，即自己不能采纳自己的答案 -->
									<c:if test="${User.userId == reply.replyPostUserId && reply.replyFromReplyUserId != reply.replyByReplyUserId }">	
										<span class="jieda-accept" type="accept"><a href="toAdopt?replyId=${reply.replyId }&postId=${post.postId }&replyFromUserId=${reply.replyFromReplyUserId }&postReward=${post.postReward }" class="layui-btn  layui-btn-small">采纳</a></span>
									</c:if>
								</div>
							</div></li>
						</c:if>
						</c:forEach>

						<!-- <li class="fly-none">没有任何回答</li> -->
					</ul>
					
					<c:if test="${User.userName != null }">	<!-- 用户登录后才可回复 -->
						<span id="toName"><a id="toReply">@${userName }</a></span>	<!-- 默认回复楼主 -->	
						<div class="layui-form layui-form-pane">
							<!-- 表单 -->
							<form action="toSubmitReply" method="post">
								<div class="layui-form-item layui-form-text">
									<div class="layui-input-block">
										<div id="editor">
											<textarea id="L_content" name="replyContent" required
											lay-verify="required" placeholder="我要回答"
											class="layui-textarea " style="height: 250px;"></textarea>
										</div>
									</div>
								</div>
								<div class="layui-form-item">
									<input type="hidden" value="${post.postId }" name="replyPostId">
									<input type="hidden" value="${post.postUserId }" name="replyPostUserId">
									<input type="hidden" value="${User.userId }" name="replyFromReplyUserId">
									<input type="hidden" value="${byReplyUserId }" name="replyByReplyUserId">
									<input class="layui-btn" value="提交回答" type="submit" />
								</div>
							</form>
						</div>
					</c:if>
					
				</div>
			</div>
		</div>

		<div class="edge">
			<dl class="fly-panel fly-list-one">
				<dt class="fly-panel-title">最近热帖</dt>
				<c:forEach items="${requestScope.postBrowse }" var="browse" varStatus="loop">
					<dd>
						<a href="">${browse.postTitle }</a> <span><i
							class="iconfont">&#xe60b;</i> ${browse.postBrowse }</span>
					</dd>
				</c:forEach>
			</dl>

			<dl class="fly-panel fly-list-one">
				<dt class="fly-panel-title">近期热议</dt>
				<c:forEach items="${requestScope.postReply }" var="reply" varStatus="loop">
					<dd>
						<a href="">${reply.postTitle }</a> <span><i
							class="iconfont">&#xe60c;</i>${reply.postReply }</span>
					</dd>
				</c:forEach>
			</dl>
		</div>
	</div>
	<!-- <div class="footer">
		<p>
			<a href="#">网博社区</a> 2017 &copy; <a href="#/">njwangbo.com</a>
		</p>
		<p>
			<a href="#" target="_blank">产品授权</a> <a href="#" target="_blank">网博社区</a>
			<a href="#" target="_blank">微信公众号</a>
		</p>
	</div> -->
	<script type="text/javascript" charset="utf-8" src="kindeditor.js"></script>
	<script type="text/javascript">
		KE.show({
			id: 'content',
			resizeMode: 1,
			cssPath: './index.css',

			items: [
				'fontname', 'fontsize', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
				'removeformat', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
				'insertunorderedlist', 'emoticons', 'image', 'link']
		});
	</script>
	<script>

		layui.cache.page = '';
		layui.cache.user = {
			username: '游客'
			, uid: -1
			, avatar: '../res/images/avatar/00.jpg'
			, experience: 83
			, sex: '男'
		};
		layui.config({
			version: "2.0.0"
			, base: '../res/mods/'
		}).extend({
			fly: 'index'
		}).use('fly');
	</script>

	<div class="site-text" style="margin: 5%; display: none" id="window" target="test123">
		<form class="layui-form" id="book" method="post" lay-filter="example">
			<div class="layui-form-item">
				<label class="layui-form-label">举报标题</label>
				<div class="layui-input-block">
					<input type="text" id="reportTitle" name="reportTitle" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">举报理由</label>
				<div class="layui-input-block">
					<textarea type="text" id="reportAccount" name="reportAccount" class="layui-textarea"></textarea>
				</div>
			</div>
	
		</form>
	</div>
	
	</body>

</html>
